#include "Camera.h"

Symbol WCamera::parse(ifstream &file, Symbol curToken) {
    Symbol nToken = matchToken(file, curToken, LBrace);
    int i;
    float *n;

    while (nToken.t != RBrace) {
        if (nToken.t == Location) {
            nToken = matchToken(file, nToken, Location);
            n = parseVector(file, nToken, &nToken, 3);

            location = vec3(n[0], n[1], n[2]);
            delete n;
        }
        else if (nToken.t == Up) {
            nToken = matchToken(file, nToken, Up);
            n = parseVector(file, nToken, &nToken, 3);
            up = vec3(n[0], n[1], n[2]);
            delete n;
        }
        else if (nToken.t == Right) {
            nToken = matchToken(file, nToken, Right);

            n = parseVector(file, nToken, &nToken, 3);

            right = vec3(n[0], n[1], n[2]);
            delete n;
        }
        else if (nToken.t == LookAt) {
            nToken = matchToken(file, nToken, LookAt);

            n = parseVector(file, nToken, &nToken, 3);

            lookAt = vec3(n[0], n[1], n[2]);
        }
    }

    
    return matchToken(file, nToken, RBrace);
}

void WCamera::print() {
    printf("Camera vectors:\n\tlocation: %f, %f, %f\n\tup"
        ": %f, %f, %f\n\tright: %f, %f, %f\n\tlookAt: %f, %f, %f\n",
        location.x, location.y, location.z, 
        up.x, up.y, up.z,
        right.x, right.y, right.z, 
        lookAt.x, lookAt.y, lookAt.z);
}

